/**
 *  Document   : Hotel
 *  Created on : 17 juil. 2008, 10:21:38
 *  Author     : Rivo
 */

package gla.centralhotel.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "hotel")
@NamedQueries({@NamedQuery(name = "Hotel.findById", query = "SELECT h FROM Hotel h WHERE h.id = :id"),
@NamedQuery(name = "Hotel.findByName", query = "SELECT h FROM Hotel h WHERE h.name = :name"),
@NamedQuery(name = "Hotel.findByAddress1", query = "SELECT h FROM Hotel h WHERE h.address1 = :address1"),
@NamedQuery(name = "Hotel.findByAddress2", query = "SELECT h FROM Hotel h WHERE h.address2 = :address2"),
@NamedQuery(name = "Hotel.findByAddress3", query = "SELECT h FROM Hotel h WHERE h.address3 = :address3"),
@NamedQuery(name = "Hotel.findByDescription", query = "SELECT h FROM Hotel h WHERE h.description = :description"),
@NamedQuery(name = "Hotel.findByServicesEquipments", query = "SELECT h FROM Hotel h WHERE h.servicesEquipments = :servicesEquipments")})
public class Hotel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "name", nullable = false)
    private String name;
    @Column(name = "address1", nullable = false)
    private String address1;
    @Column(name = "address2")
    private String address2;
    @Column(name = "address3")
    private String address3;
    @Column(name = "description", nullable = false)
    private String description;
    @Column(name = "services_equipments")
    private String servicesEquipments;
    @JoinColumn(name = "ref_manager", referencedColumnName = "id")
    @ManyToOne
    private Manager refManager;
    
//    // version 2.0.1 de la base
    @JoinColumn(name = "ref_zipcode", referencedColumnName = "id")
    @ManyToOne
    private Zipcode refZipcode; 
    
//    // version 2.1 de la base
//    @JoinColumn(name = "ref_country", referencedColumnName = "id")
//    @ManyToOne
//    private Country refCountry;

    
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refHotel")
//    private Collection<Room> roomCollection;

    public Hotel() {
    }

    public Hotel(Integer id) {
        this.id = id;
    }

    public Hotel(Integer id, String name, String address1, String description) {
        this.id = id;
        this.name = name;
        this.address1 = address1;
        this.description = description;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress1() {
        return address1;
    }

    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    public String getAddress3() {
        return address3;
    }

    public void setAddress3(String address3) {
        this.address3 = address3;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getServicesEquipments() {
        return servicesEquipments;
    }

    public void setServicesEquipments(String servicesEquipments) {
        this.servicesEquipments = servicesEquipments;
    }

    public Manager getRefManager() {
        return refManager;
    }

    public void setRefManager(Manager refManager) {
        this.refManager = refManager;
    }
    
    // base version 2.0.1
    public Zipcode getRefZipcode() {
        return refZipcode;
    }

    public void setRefZipcode(Zipcode refZipcode) {
        this.refZipcode = refZipcode;
    }
    // fin base version 2.0.1
    
// version 2.1 de la base
//    public Country getRefCountry()
//    {
//        return refCountry;
//    }
//
//    public void setRefCountry(Country refCountry)
//    {
//        this.refCountry = refCountry;
//    }
// fin version 2.1 de la base
    
// modif rivo
//    public Collection<Room> getRoomCollection() {
//        return roomCollection;
//    }
//
//    public void setRoomCollection(Collection<Room> roomCollection) {
//        this.roomCollection = roomCollection;
//    }
// modif rivo
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hotel)) {
            return false;
        }
        Hotel other = (Hotel) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gla.centralhotel.model.Hotel[id=" + id + "]";
    }
}
